package cn.bsuc.infirmary.service.impl;

import cn.bsuc.infirmary.domain.Drug;
import cn.bsuc.infirmary.mapper.DrugMapper;
import cn.bsuc.infirmary.query.QueryObject;
import cn.bsuc.infirmary.service.IDrugService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DrugServiceImpl implements IDrugService {
    @Autowired
    private DrugMapper drugMapper;

    @Override
    public void save(Drug s) {
        drugMapper.insert(s);
    }

    @Override
    public void update(Drug s) {
        drugMapper.updateByPrimaryKey(s);
    }

    @Override
    public PageInfo<Drug> queryList(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize());
        List<Drug> list = drugMapper.queryList(qo);
        return new PageInfo<Drug>(list);
    }
}
